fn main() {

    



    // 元组:固定长度异构集合,数据类型可不用
    let t1 = (0, "hello", 3.14);
    println!("t1 is:{},{},{}",t1.0,t1.1,t1.2);

    let mut t2 = (1, "hi", 0.2);
    println!("t2 second element:{}",t1.1);   // t2 second element:hello
    // 元组通过.索引来访问内部元素
    t2.1 = "bye";
    println!("t2 second element:{}",t1.1);   // t2 second element:hello



    println!("l2_4元组和数组");


    // 数组:固定长度同构集合,数据类型相同
    let mut arr  = [0,1,2];
    arr[0] = 100;
    println!("arr len is:{}, first element is  {}", arr.len(), arr[0]);  // arr len is:3, first element is  100

    // 遍历数组
    for ele in arr {
        println!("元素值为:{}",ele);
    }

    // 包含重复元素的数组定义,包含20个3
    let arr1 = [3;20];
    for ele in arr1 {
        println!("{}", ele);
    }



    // copy属性: 基础数据类型重新赋值执行copy, 复杂数据类型重新赋值执行move,所有权会发生转移
    let arr_item = [1,2,3];
    let tuple_item = (1, "abc");
    println!("{:?}", arr_item);
    println!("{:?}",tuple_item);

    let arr_ownership = arr_item;
    let tup_ownership = tuple_item;
    println!("{:?}", arr_ownership);
    println!("{:?}",tup_ownership);
    println!("{:?}", arr_item);
    println!("{:?}",tuple_item);

    // move属性：string, 结构体struct,
    let s1 = "zhangsan".to_string();
    println!("{:?}", s1); 
    // s1拥有的数据所有权转移给了s2, 之后s1就不存在了
    let s2 = s1;   // 报错: value borrowed here after move
    // println!("{:?}", s1);

}
